package com.abhimanyu.dataaccess.jpa;

import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;

import org.springframework.transaction.annotation.Transactional;

import com.abhimanyu.dataaccess.IDao;

public abstract class AbstractDao<T> implements IDao<T> {

	@PersistenceContext
	private EntityManager entityManager;
 
	@Transactional
	public void save(T object) {
		System.out.println("Saving... : " + object);
		getEntityManager().persist(object);
		System.out.println("Saved");
	}

	public EntityManager getEntityManager() {
		return entityManager;
	}

	public void setEntityManager(EntityManager entityManager) {
		this.entityManager = entityManager;
	}

}
